﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web.Http;
using Orchard;
using Ascent.XinKuanKong.Services;
using Orchard.Settings;
using MongoDB.Driver;
using Top.Api.Domain;
using Orchard.Logging;

namespace Ascent.XinKuanKong.Controllers
{
    public class ItemsController : ApiController
    {
        private readonly IOrchardServices _orchardServices;
        private readonly IXinKuanKongService _xinkuankongService;
        private readonly ISiteService _siteService;
        protected ILogger Logger { get; set; }

        public ItemsController(
            IOrchardServices orchardServices, 
            IXinKuanKongService xinkuankongService,
            ISiteService siteService) {
            _orchardServices = orchardServices;
            _xinkuankongService = xinkuankongService;
            _siteService = siteService;
            Logger = NullLogger.Instance;
        }

        private MongoDatabase MongoDatabase { get { return _xinkuankongService.MongoDatabase; } }
        private MongoCollection<Shop> ShopCollection { get { return MongoDatabase.GetCollection<Shop>("shops"); } }
        private MongoCollection<Item> ItemCollection { get { return MongoDatabase.GetCollection<Item>("items"); } }


        // GET /api/<controller>
        public IEnumerable<Item> Get()
        {
            return ItemCollection.FindAll().AsEnumerable();
        }

        // GET /api/<controller>/5
        public string Get(int id)
        {
            return "value";
        }

        // POST /api/<controller>
        public void Post(string value)
        {
        }

        // PUT /api/<controller>/5
        public void Put(int id, string value)
        {
        }

        // DELETE /api/<controller>/5
        public void Delete(int id)
        {
        }
    }
}